<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 50px;
            background-color: #000;
            border-radius: 20px;
            margin: auto;
            color: chartreuse;
            text-align: center;
            font-weight: 700;
            line-height: 50px;
            font-size: 20px;
        }

        div span {
            letter-spacing: 0.3em;
        }
    </style>
</head>

<body>
    <div>
        <span>18</span>:
        <span>10</span>:
        <span>20</span>
    </div>

</body>
<script>
    setInterval(function () {
        let date = new Date();
        let h = date.getHours(); //时
        let m = date.getMinutes(); //分
        m = checkTime(m);
        let s = date.getSeconds(); //秒
        s = checkTime(s);
        let spanArr = document.getElementsByTagName('span');
        spanArr[0].innerText = h;
        spanArr[1].innerText = m;
        spanArr[2].innerText = s;
    }, 100)

    //使数字为两位
    function checkTime(t) {
        if (t < 10) {
            t = '0' + t;
        }
        return t;
    }
</script>

</html>